package com.p2p.front.dal.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.p2p.base.dao.BaseMapper;
import com.p2p.front.dal.model.BorrowerPhoto;

public interface BorrowerPhotoDao extends BaseMapper{
	
	@Select("select * from p2p_borrower_photo where uid =#{uid} and type=#{type} and status=0")
	List<BorrowerPhoto> findByUid(@Param("uid")Long uid,@Param("type")Integer type);
	
	@Insert("insert into p2p_borrower_photo(no,uid,url,addtime,status,type) values(#{no},#{uid},#{url},#{addtime},#{status},#{type})")
	void save(BorrowerPhoto photo);
	
	@Select("select * from p2p_borrower_photo where id =#{id}")
	BorrowerPhoto findById(Long id);
	
	@Delete("delete from p2p_borrower_photo where id =#{id}")
	void deleteById(Long id);
	
	@Update("update p2p_borrower_photo set status =#{status}  where id = #{id}")
	void updateImageStatus(@Param("id")Long id,@Param("status") int status);

	@Update("update p2p_borrower_photo set status=1 where uid =#{uid} and type=#{type}")
	void removeByUidAndType(@Param("uid")String uid,@Param("type")Integer type);
}
